const mongoose = require('mongoose')

const Schema = mongoose.Schema

const commentSchema = new Schema({
    email:{
        type:String,
        required:true,
        match:/[a-zA-Z0-9_]{3,20}@[a-zA-Z0-9_.]{1,20}/
    },
    nickname:{
        type:String,
        required:true,
        maxlength:32,
    },
    comment:{
        type:String,
        required:true,
        maxlength:512
    },
    //文档和文档之间通过id来引用
    image:{
        type:Schema.Types.ObjectId,
        required:true
    }
},{timestamps:true})

mongoose.model('Comment',commentSchema,'comment')